import { BaseEntity } from 'src/common/base.entity'
import { Entity, Column, ManyToOne } from 'typeorm'
import { User } from './user.entity'

export enum TargetType {
  ITEM = 'ITEM', // 商品评价
  ORDER = 'ORDER', // 订单评价
  COMMENT = 'COMMENT' // 评论回复
}

export enum ReviewType {
  POSITIVE = 'POSITIVE', // 好评
  MODERATE = 'MODERATE', // 中评
  NEGATIVE = 'NEGATIVE' // 差评
}

@Entity()
export class Comment extends BaseEntity {
  @Column()
  targetId: string

  @Column({
    type: 'enum',
    enum: TargetType
  })
  targetType: TargetType

  @Column()
  content: string

  @Column({
    type: 'enum',
    enum: ReviewType,
    nullable: true
  })
  reviewType?: ReviewType

  @ManyToOne(() => User, (user) => user.items)
  user: User
}
